﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace System
{
    /// <summary>
    /// Extension methods for Form class
    /// </summary>
    public static class FormExt
    {
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="def">The definition.</param>
        /// <param name="options">The options.</param>
        /// <returns></returns>
        public static DialogResult ShowDialog(this Form form, string text, string caption, 
            MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton def, 
            MessageBoxOptions options)
        {
            return MessageBox.Show(form, text, caption, buttons, icon, def, options);
        }
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="icon">The icon.</param>
        /// <returns></returns>
        public static DialogResult ShowDialog(this Form form, string text, string caption,
            MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            return MessageBox.Show(form, text, caption, buttons, icon);
        }

        #region Info
        /// <summary>
        /// Shows the information dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <param name="caption">The caption.</param>
        /// <returns></returns>
        public static DialogResult ShowInfoDialog(this Form form, string text, string caption)
        {
            return form.ShowDialog(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        /// <summary>
        /// Shows the information dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <returns></returns>
        public static DialogResult ShowInfoDialog(this Form form, string text)
        {
            return ShowInfoDialog(form, text, Application.ProductName);
        }
        #endregion

        #region Error
        /// <summary>
        /// Shows the error dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <param name="caption">The caption.</param>
        /// <returns></returns>
        public static DialogResult ShowErrorDialog(this Form form, string text, string caption)
        {
            return form.ShowDialog(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        /// <summary>
        /// Shows the error dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <returns></returns>
        public static DialogResult ShowErrorDialog(this Form form, string text)
        {
            return ShowErrorDialog(form, text, Application.ProductName);
        }
        #endregion

        #region Warning
        /// <summary>
        /// Shows the warning dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <param name="caption">The caption.</param>
        /// <returns></returns>
        public static DialogResult ShowWarningDialog(this Form form, string text, string caption)
        {
            return form.ShowDialog(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }

        /// <summary>
        /// Shows the warning dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <returns></returns>
        public static DialogResult ShowWarningDialog(this Form form, string text)
        {
            return ShowWarningDialog(form, text, Application.ProductName);
        }
        #endregion

        #region Yes No Question
        /// <summary>
        /// Shows the Yes No question dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <param name="caption">The caption.</param>
        /// <returns></returns>
        public static DialogResult ShowYNQuestionDialog(this Form form, string text, string caption)
        {
            return form.ShowDialog(text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        }

        /// <summary>
        /// Shows the yn question dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <returns></returns>
        public static DialogResult ShowYNQuestionDialog(this Form form, string text)
        {
            return ShowYNQuestionDialog(form, text, Application.ProductName);
        }
        #endregion

        #region Yes No Cancel Question
        /// <summary>
        /// Shows the Yes No Cancel question dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <param name="caption">The caption.</param>
        /// <returns></returns>
        public static DialogResult ShowYNCQuestionDialog(this Form form, string text, string caption)
        {
            return form.ShowDialog(text, caption, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
        }

        /// <summary>
        /// Shows the ync question dialog.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="text">The text.</param>
        /// <returns></returns>
        public static DialogResult ShowYNCQuestionDialog(this Form form, string text)
        {
            return ShowYNCQuestionDialog(form, text, Application.ProductName);
        }
        #endregion

        /// <summary>
        /// Removes the system menu.
        /// </summary>
        /// <param name="form">The form.</param>
        public static void RemoveSystemMenu(this Form form)
        {
            User32.RemoveSystemMenu(form);
        }
    }
}
